import os
import os.path

from arkaiv.lib.base import model
from arkaiv.model.framer import Frame

class Imager:

    def createimageforclip(self, cmmlfile, clipinfo):
            basename = os.path.splitext(cmmlfile)[0]
            imagedirname = basename + "_clipimages"
            clipimagename = str(clipinfo['starttime']) + ".png"
            oggsource = model.getsourcepath(clipinfo['itemid'])
            cwd = os.getcwd()
            os.chdir(imagedirname)  # ugly...
            frameimage = Frame(oggsource, float(clipinfo['starttime']), clipimagename)    
            print "after frameimage"
            os.chdir(cwd)   # very ugly... #
    
            # add that info to the dictionary - only needs to be a relative
            # location
            relpath = os.path.split(imagedirname)[1]
            imagefile = relpath + "/" + clipimagename
            return imagefile

